document.addEventListener('DOMContentLoaded', function() {
    var likesbtn = document.getElementById('likes-btn')
    // var likecounts = document.getElementById('likecounts')
    var likecount = document.getElementsByClassName('likecount')
    var i = 0
    likesbtn.addEventListener('click',function(){
        fetch(
            '/images/likes/' + likesbtn.dataset.imageid,
            {method: 'POST',body: {}},
        ).then(response => response.json())
        for (i = 0; i < likecount.length; i++) {
            likecount[i].innerHTML = parseInt(likecount[i].innerHTML)+1 
        }
        // .then(
        //     likecount.innerHTML = parseInt(likecount.innerHTML)+1
        // )
    })
})
